package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.ProductSku;
import top.tsyz.service.IProductSkuService;

import java.util.List;

/**
 * ProductSkuController控制器
 */
@RestController
@RequestMapping("/api/productSkus")
@Api(tags = "ProductSku管理接口")
public class ProductSkuController {

    @Autowired
    private IProductSkuService iproductskuservice;

    @GetMapping("/list")
    @ApiOperation("获取所有ProductSku")
    public List<ProductSku> list() {
        return iproductskuservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取ProductSku")
    public ProductSku getById(@PathVariable Long id) {
        return iproductskuservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增ProductSku")
    public boolean save(@RequestBody ProductSku productsku) {
        return iproductskuservice.save(productsku);
    }

    @PutMapping
    @ApiOperation("更新ProductSku")
    public boolean update(@RequestBody ProductSku productsku) {
        return iproductskuservice.updateById(productsku);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除ProductSku")
    public boolean delete(@PathVariable Long id) {
        return iproductskuservice.removeById(id);
    }
}
